/**
 * @file listener_serial.cpp
 * @author circleup (circleup@foxmail.com)
 * @brief GPS 观光车状态数据监听节点，订阅 serial_receive_data 话题
 * @version 2.6
 * @date 2020-07-06
 * 
 * @copyright Copyright (c) 2020
 * 
 */

#include "ros_serial_driver.h"

#include <math.h>

/**
 * @brief 观光车状态数据回调函数
 * 
 * @param msg serial_receive_data 话题消息
 */
void chatterCallback(const ros_car::car_status_frame::ConstPtr& msg);

int main(int argc, char **argv)
{
  ros::init(argc, argv, "listener_serial");

  ROS_INFO("This is listener_serial");

  ros::NodeHandle n;

  ros::Subscriber receive = n.subscribe("serial_receive_data", 1000, chatterCallback);


  ros::spin();

  return 0;
}

void chatterCallback(const ros_car::car_status_frame::ConstPtr& msg)
{


  ROS_INFO("msg.heading is %f",msg->heading);
  ROS_INFO("msg.lattitude is %f",msg->lattitude);
  ROS_INFO("msg.longitude is %f",msg->longitude);
  ROS_INFO("msg.velocity is %f",msg->velocity);
  
  WriteToFile(*msg);
}